Programming languages such as Java, C++, Lisp, Smalltalk, and several scripting languages allocate memory from such an area known as the heap (or heap memory). At any given time, some parts of the heap may be in use while parts may be “free” (i.e., unused) and thus available for future allocations. In order to free memory from the heap, garbage collection is needed. A key problem with such environments is that memory overhead is a significant factor.
Programmers cannot manually allocate or deallocate memory objects. Programmers need to rely on garbage collectors (i.e., one or more garbage collectors are normally available in the operating system) to free up memory which is no longer being used. In many cases, this can result in excess memory being allocated to the heap.
Such excess heap memory being allocated to one or more applications operating in a computer system environment can create serious memory management problems for the computer system. These problems are particularly difficult to deal with in situations in which multiple applications are running on the same computer system, and the applications are all competing for memory. For example, multiple Java virtual machines (JVM) might be running on the same information processing system concurrently, competing with each other for memory (as well as other resources). The idea is to allocate memory efficiently across all applications. Memory should be properly distributed across all of the JVMs on the system. A key problem is how to allocate memory across the system for optimal performance among all of the JVMs.
Java allocates memory from an area known as the heap. In order to free memory from the heap, garbage collection is needed. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program.
In summary, memory management is the process of managing computer memory, including mechanisms to dynamically allocate portions of memory to programs upon request and freeing memory for reuse when no longer needed. Memory requests are satisfied by allocating portions from a large pool of memory referred to as “the heap”, and, at any given time, some parts of the heap are in use while some are “free” (i.e., unused) and thus available for future allocations. While ideally memory should be properly distributed across all of the JVMs on the system, conventional system have failed to do this in an optimal fashion. Conventional system designs regularly struggle with how to allocate memory across the system for optimal performance among all of the JVMs, with often less than satisfactory results.
Garbage collection is a form of automatic memory management that attempts to reclaim “garbage”, as referring to memory occupied by objects that are no longer in use by a program. Garbage collection is often portrayed as the opposite of manual memory management, a mechanism in which the programmer specifies which objects to deallocate and return to the memory system. Many computer languages, such as Java, C++, and several scripting languages, require garbage collection either as part of the language specification or effectively for practical implementation, while other languages, such as C, C++, were designed for use with manual memory management but have garbage collected implementations available. Still others, such as Ada, Modula-3, and C++/CLI allow both garbage collection and manual memory management to co-exist in the same application by using separate heaps, and others, such as D, are garbage collected while allowing the user to manually delete objects and disable garbage collection when speed is required.